package com.mymarkdown.app.model;

import com.mymarkdown.app.interfaces.UserInfoService;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.File;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;

/**
 * @author zenglun
 * @date 2021/12/15 9:14 下午
 * @description: TODO
 */
@Getter
@Setter
@Accessors(chain = true)
public class AppWindowInfo {
    private boolean isSave;
    private UserInfoService userInfoService;
    private static AppWindowInfo self = new AppWindowInfo();
    private AppWindowInfo(){}

    public static AppWindowInfo getInstance(UserInfoService userInfoService){
        if (Objects.isNull(userInfoService)){
            throw new NullPointerException("用户信息为空!");
        }
        self.userInfoService = userInfoService;
        return self;
    }

    public String getFilename() {
        BlockingQueue<File> operationFile = this.userInfoService.getOperationFile();
        File peek = operationFile.peek();
        if (Objects.isNull(peek)){

            return null;
        }
        return peek.getName();
    }
}
